#pragma once

#include <vector>
#include <string>

namespace http
{
    namespace middleWare
    {
        //跨域配置
        struct CorsConfig
        {
            std::vector<std::string> allowedOrigins;//允许的源
            std::vector<std::string> allowedMethods;//允许的请求方法
            std::vector<std::string> allowedHeaders;//允许的请求头
            bool allowCredentials = false;//是否允许携带cookie
            int maxAge = 3600;//缓存时间
            static CorsConfig defaultConfig() 
            {
                CorsConfig config;
                config.allowedOrigins = {"*"};
                config.allowedMethods = {"GET", "POST", "PUT", "DELETE", "OPTIONS"};
                config.allowedHeaders = {"Content-Type", "Authorization"};
                return config;
            }
        };
        
    }
}   